/*
 * Copyright 2009 Johnson Consulting Services
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.johnsoncs.gwt.widgets.server.export;

import java.io.InputStream;
import java.io.OutputStream;

import com.johnsoncs.gwt.widgets.client.dynamictable.export.ExportException;

/**
 * Defines a class capable of storing export results
 * @author wilj
 *
 */
public interface ExportStorage {
	/**
	 * Deletes the exported file (if supported)
	 * @param fileName the export result file to delete
	 * @throws ExportException
	 */
	public void deleteExportResult(String fileName) throws ExportException;

	/**
	 * Provides the ExportStorage impl class the opportunity to do any cleanup necessary
	 * @param fileName the export result file to finalize
	 * @throws ExportException
	 */
	public void finalizeExportResult(String fileName) throws ExportException;

	/**
	 * Returns an InputStream to the export result file
	 * @param fileName the export result file to open
	 * @return InputStream to the export result file, or null if the file is not found
	 * @throws ExportException
	 */
	public InputStream getExportResult(String fileName) throws ExportException;

	/**
	 * Initializes the storage of an export result
	 * @param fileName the name of the export result to create
	 * @return OutputStream to which the export results can be written
	 * @throws ExportException
	 */
	public OutputStream initExportResult(String fileName) throws ExportException;
}
